package com.hua.api.core.framework.util.exception;

public class ApiError extends RuntimeException {


    public int errorCode;

    public String hint;


    public ApiError(){

    }

    public ApiError(int errorCode, String errMessage, String errHint) {
        // super(errMessage);
        super(errHint);
        this.hint = errHint;
        this.errorCode = errorCode;
    }

    public int getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(int errorCode) {
        this.errorCode = errorCode;
    }

    public String getHint() {
        return hint;
    }

    public void setHint(String hint) {
        this.hint = hint;
    }

    public String toJsonString(){
        return null;
    }


    public static enum Type {
        TOKEN_ERROR(300, "token错误"),
        ENTITY_ERROR(5001, "数据不存在"),
        MEITUAN_API_ERROR(4000, "美团接口错误"),
        EXPRESS_API_ERROR(4001, "快递接口错误"),
        BENLAI_API_ERROR(4002, "本来生活接口错误"),
        CHANNEL_API_ERROR(4003, "已转在下游系统中"),
        LOGIC_ERROR(4004, "逻辑错误");

        private int errorCode;
        private String hint;

        private Type(int errorCode, String hint) {
            this.errorCode = errorCode;
            this.hint = hint;
        }
        public int getErrorCode() {
            return this.errorCode;
        }
        public String getHint() {
            return this.hint;
        }
        public ApiError toException() {
            return new ApiError(errorCode, this.name(), hint);
        }
        public ApiError toException(String error) {
            return new ApiError(errorCode, this.name(), error);
        }
    }

}
